library zlg_sms;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }
uses
  SysUtils,
  Windows,
  Classes,
  unit_sms in 'unit_sms.pas';

{$R *.res}
var
  _com : word;
  _fpoint : tfarproc;
  _zlg : TZlg_SMS;
//ctor
procedure zlg_sms_ctor; stdcall;
begin
  _zlg := tzlg_sms.Create;
end;
//destry
procedure zlg_sms_destory; stdcall;
begin
  try
    if(_zlg <> nil)then
      _zlg.Destroy;
  except
  end;
  _zlg := nil;
end;
//start
function zlg_sms_start : boolean; stdcall;
begin
  result := false;
  if(_zlg = nil)then
    exit;
  _zlg.Start(_com, _fpoint);
end;
//stop
procedure zlg_sms_stop; stdcall;
begin
  if(_zlg = nil)then
    exit;
  _zlg.Stop;
end;
//
function zlg_sms_state : boolean; stdcall;
begin
  result := false;
  if(_zlg = nil)then
    exit;
  result := _zlg.state;
end;
//
procedure zlg_sms_parameter(com : word; fpoint : tfarproc);stdcall;
begin
  _fpoint := fpoint;
  _com := com;
end;
//
procedure zlg_sms_sendsms(phone : pchar; sms : pchar); stdcall;
var
  p : string;
  s : string;
begin
  if(_zlg = nil)then
    exit;
  p := phone;
  s := sms;
  _zlg.sendSms(p, s);
end;

exports
  zlg_sms_ctor,
  zlg_sms_destory,
  zlg_sms_start,
  zlg_sms_stop,
  zlg_sms_state,
  zlg_sms_parameter,
  zlg_sms_sendsms;
end.
